/*
 * @Author: szx
 * @Date: 2022-06-13 14:27:50
 * @LastEditTime: 2022-06-13 14:35:31
 * @Description:
 * @FilePath: \leetcode\面试题\17\04\04.js
 */
/**
 * @param {number[]} nums
 * @return {number}
 */
var missingNumber = function (nums) {
    const n = nums.length;
    return ((n + 1) * n) / 2 - nums.reduce((a, b) => a + b, 0);
};
var missingNumber = function (nums) {
    let xor = 0;
    const n = nums.length;
    nums.forEach((v) => (xor ^= v));
    for (let i = 0; i <= n; i++) xor ^= i;
    return xor;
};
